#pragma once
#include "PdfIrmProtector.h"
#include "resource.h"       
#include <comsvcs.h>
#include "Globals.h"
#include "strsafe.h"

class ATL_NO_VTABLE CPdfProtector :public I_IrmProtector,
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CPdfProtector, &CLSID_PdfProtector>
	
{
public:
	CPdfProtector();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_PDFPROTECTOR)

DECLARE_NOT_AGGREGATABLE(CPdfProtector)

BEGIN_COM_MAP(CPdfProtector)
	COM_INTERFACE_ENTRY(I_IrmProtector)

END_COM_MAP()

public:	    
    ~CPdfProtector();

public:
    __override STDMETHOD(HrInit)           (BSTR *pbstrProduct, DWORD *pdwVersion, BSTR *pbstrExtensions, BOOL *pfUseRMS);
    __override STDMETHOD(HrIsProtected)    (ILockBytes *pilbInput, DWORD *pdwResult);
    __override STDMETHOD(HrSetLangId)      (LANGID langid);
    __override STDMETHOD(HrProtectRMS)     (ILockBytes *pilbInput, ILockBytes *pilbOutput, I_IrmPolicyInfoRMS *piid, DWORD *pdwStatus);
    __override STDMETHOD(HrUnprotectRMS)   (ILockBytes *pilbInput, ILockBytes *pilbOutput, I_IrmPolicyInfoRMS *piid, DWORD *pdwStatus);
    __override STDMETHOD(HrProtect)        (ILockBytes *pilbInput, ILockBytes *pilbOutput, I_IrmPolicyInfo *piid, DWORD *pdwStatus);
    __override STDMETHOD(HrUnprotect)      (ILockBytes *pilbInput, ILockBytes *pilbOutput, I_IrmPolicyInfo *piid, DWORD *pdwStatus);

protected:
    __override WCHAR *WzRegKey();

protected:
    unsigned int m_uRefCount;

    LANGID       m_langid;
};

OBJECT_ENTRY_AUTO(__uuidof(PdfProtector), CPdfProtector)
